package com.leoman.plz_p.presenter;


import com.leoman.plz_p.interfaces.AnswerQuestionView;
import com.leoman.plz_p.module.api.ExamApi;
import com.leoman.plz_p.module.bean.BaseData;
import com.leoman.plz_p.module.bean.QuestionBean;
import com.leoman.plz_p.subscriber.ResponseSubscriber;

import cn.com.corelib.api.ResponseTransformer;
import cn.com.corelib.base.BasePresenter;

public class AnswerQuestionPresenter extends BasePresenter<AnswerQuestionView> {

    private ExamApi examApi;

    @Override
    protected void onViewAttach() {
        super.onViewAttach();
        examApi=getApi(ExamApi.class);
    }

    public void getQuestionDetail(String id){
        examApi.getQuestionDetail(id).compose(new ResponseTransformer<>(this.<BaseData<QuestionBean>>bindToLifeCycle()))
                .subscribe(new ResponseSubscriber<BaseData<QuestionBean>>(view) {
                    @Override
                    public void success(BaseData<QuestionBean> questionBeanBaseData) {
                        view.obtainQuestionDetail(questionBeanBaseData.data);
                    }
                });
    }

    @Override
    public void onStart() {

    }
}